using System;
using Gadgeteer.Modules;

namespace Gadgeteer.Interfaces.Network
{
    public interface INetworkModule
    {
        /// <summary>
        /// Raised when the network connection is not able to perform network communication tasks.
        /// </summary>
        /// <remarks>
        /// Handle this event to perform tasks associated with the network state.  This
        /// event is raised when Gadgeteer.Modules.Module.NetworkModule.NetworkState
        /// changes from NetworkState.Up to NetworkState.Down. If the network is down
        /// when you add an event handler, the event is raised immediately on the new
        /// handler.
        /// </remarks>
        event NetworkEventHandler NetworkDown;

        /// <summary>
        /// Raised when network is connected and configured for Internet Proctocol (IP)
        ///  communication tasks.
        /// </summary>
        /// <remarks>
        /// Handle this event to perform tasks associated with the network state.  This
        /// event is raised when Gadgeteer.Modules.Module.NetworkModule.NetworkState
        /// changes from NetworkState.Down to NetworkState.Up. If the network is up when
        /// you add an event handler, the event is raised immediately on the new handler.
        /// When this event is raised, it does not necessarily mean that the network
        /// connection is functional. The IP configuration for the network connection
        /// may be invalid for the network that it is connected to.
        /// </remarks>
        event NetworkEventHandler NetworkUp;

        /// <summary>
        /// Gets a value that indicates whether this network is connected.
        /// </summary>
        /// <remarks>
        /// Derived classes override this property to return a value that indicates whether
        /// the media state is connected. This does not necessarily mean that the network
        /// connection is functional.
        /// </remarks>
        bool IsNetworkConnected { get; }

        /// <summary>
        /// Gets a value that indicates whether the network connection is up.
        /// </summary>
        /// <remarks>
        /// When this property is true, the network connection is connected (Gadgeteer.Modules.Module.NetworkModule.IsNetworkConnected
        /// is true) and IP settings are configured (either statically or using DHCP
        /// as requested).
        /// When this property is true, it does not necessarily mean that the network
        /// connection is functional. The IP configuration for the network connection
        /// may be invalid for the network that it is connected to.
        /// </remarks>
        bool IsNetworkUp { get; }

        /// <summary>
        /// Gets a NetworkInterface object that describes the settings associated with this network module.
        /// </summary>
        /// <remarks>
        INetworkInterface NetworkSettings { get; }

        /// <summary>
        /// Instructs the network connection to use the Dynamic Host Configuration Protocol 
        /// (DHCP) to obtain its IP configuration.
        /// </summary>
        void UseDHCP();
        
        /// <summary>
        /// Instructs the network connection to use a static Internet Protocol (IP) configuration.
        /// </summary>
        /// <param name="IPAddress">The IP address.</param>
        /// <param name="SubnetMask">The subnet mask.</param>
        /// <param name="GatewayAddress">The IP address for the default gateway.</param>
        void UseStaticIP(string IPAddress, string SubnetMask, string GatewayAddress);

        /// <summary>
        /// Instructs the network connection to use a static Internet Protocol (IP) configuration.
        /// </summary>
        /// <param name="IPAddress">The IP address.</param>
        /// <param name="SubnetMask">The subnet mask.</param>
        /// <param name="GatewayAddress">The IP address for the default gateway.</param>
        /// <param name="DnsAddresses">The IP address of each Domain Name Server (DNS) that this network connection can use.</param>
        /// <remarks>Pass null to DnsAddresses to disable static DNS.</remarks>
        void UseStaticIP(string IPAddress, string SubnetMask, string GatewayAddress, string[] DnsAddresses);

    }
}
